package org.zhxy.zhxy.utils;


import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@Component
public class SendEmailUtils {

    public static final String MAIL_SENDER="chpincp@qq.com";

    @Resource
    private JavaMailSender javaMailSender;

    /**
     * 发送邮件
     * @param email 接收者邮箱
     * @param title 邮件标题
     * @param text  邮件内容
     */
    public  void sendEmail(String email,String title,String text){
        try {
            SimpleMailMessage mailMessage= new SimpleMailMessage();
            mailMessage.setFrom(MAIL_SENDER);//发送者
            mailMessage.setTo(email);//接收者
            mailMessage.setSubject(title);//邮件标题
            mailMessage.setText(text);//邮件内容
            javaMailSender.send(mailMessage);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
